﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace Project01
{
    //Dùng để phân chia vị trí di chuyển của monster
    public enum MonsterMove
    { Left, Center, Right }
    class Monster : ObjectGame
    {
        protected int Health;
        protected float Speed;
        protected Explosion Exp;
        protected bool IsDead ;
        public List<Bullets> Mbullets = new List<Bullets>();
        public MonsterMove MoveState;
        public bool Active = false;
        public byte Type;
        
       

        protected Monster(Game game)
            : base(game)
        {
            Exp = new Explosion(game, "Images/Explosion/Explosion", 2, 4);
            
        }
        //Methods dùng để set Position của Bullets theo monster
        public virtual void SetHealth(int Damage)
        {
            Health -= Damage;
        }
        public virtual bool Destroy()
        {
            if (Health <= 0)
            {
                return true;
            }
            return false;
        }
        protected bool CheckPosition(Vector2 Position)
        {
            if (this.Sprite.Position.Y >= game.Window.ClientBounds.Height + Sprite.RecHeight)
                return true;
            return false;
        }
        protected Vector2 SetPositionExplosion(Vector2 Position, float DistanceX, float DistanceY)
        {
            return new Vector2(Position.X + DistanceX, Position.Y + DistanceY);
        }
        public override void Update(GameTime gameTime)
        {
            IsDead =Destroy();
           if (IsDead)
            {

                Exp.Update(gameTime);
                if (Exp.Sprite.currentFrame == Exp.Sprite.totalFrame-1)
                {
                    Active = true;
                }
            }
           Sprite.Update();
            base.Update(gameTime);
        }
        public virtual void CreateBullets(Vector2 Position) { }
        public virtual void UpdateBullets(GameTime gameTime) { }
        public override void Draw(SpriteBatch SpriteBatch)
        {
            this.Sprite.Draw(SpriteBatch);
             if (IsDead)
            Exp.Draw(SpriteBatch);
            base.Draw(SpriteBatch);
        }


    }
}
